//
//  SRCurrentData+Cate.m
//  SportRing
//
//  Created by mykoma on 14/11/15.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRCurrentData+Cate.h"

@implementation SRCurrentData (Cate)

+ (SRCurrentData *)currentDataForMe:(SRMe *)me
{
    __block SRCurrentData * data = nil;
    [MagicalRecord saveUsingCurrentThreadContextWithBlockAndWait:^(NSManagedObjectContext *localContext)
     {
         data = [SRCurrentData MR_createEntity];
         data.current = [SRCurrent findCurrentCINEForMe:me];
     }];
    return data;
}

- (void)configAttributesWithBlock:(void(^)(SRCurrentData * aSelf))block
{
    [MagicalRecord saveUsingCurrentThreadContextWithBlockAndWait:^(NSManagedObjectContext *localContext)
     {
         block(self);
     }];
}

@end

@implementation SRCurrentData (Find)

+ (SRCurrentData *)findCurrentDataForMe:(SRMe *)me
{
    return me.current.data;
}

+ (SRCurrentData *)findCurrentDataCINEForMe:(SRMe *)me
{
    SRCurrentData * data = [SRCurrentData findCurrentDataForMe:me];
    if (data == nil) {
        data = [SRCurrentData currentDataForMe:me];
    }
    return data;
}

+ (float)currentMileage:(SRMe *)me
{
    return 0;
}

+ (float)currentCalorie:(SRMe *)me
{
    return 0;
}

+ (float)currentRunCounter:(SRMe *)me
{
    return 0;
}

+ (float)currentUpStairCounter:(SRMe *)me
{
    return 0;
}

+ (float)currentWalkCounter:(SRMe *)me
{
    return 0;
}

@end